package Offer;

/**
 * 数组中数字出现的次数
 * @author 是阿秋啊
 * @date 2022/04/21 19:26
 **/
public class Num56 {
    public int[] singleNumbers(int[] nums) {
        int num = 0;
        for (int i : nums) {
            num ^=i;
        }
        int m = 1;
        // 找位
        while ((num & m) == 0) {
            m<<=1;
        }
        int a = 0,b = 0;
        for (int i : nums) {
            if ((i & m) != 0) {
                a^=i;
            }else {
                b^=i;
            }
        }
        return new int[]{a,b};
    }
}
